<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script type="application/javascript">
        function enroll(){
            let xhr = new XMLHttpRequest();
            xhr.onreadystatechange=function (){
                if(xhr.status==200 && xhr.readyState==4){
                    let data = xhr.responseText;
                    alert(JSON.parse(data));
                }
            }
            let userName= document.getElementById("userName").value;
            let password=document.getElementById("password").value;
            function User(userName,password,state) {
                this.userName=userName;
                this.password=password;
                this.state=state;
            }
            let user=new User(userName,password,null);
            alert(JSON.stringify(user))
            xhr.open("post",
                "localhost:80/enroll",
                false);
            xhr.send(JSON.stringify(user));

        }
    </script>
</head>
<body>
<div class="center">
    <form action="/enroll" method="get">
        昵称<input type="text" name="userName" id="userName"/>
        <br>
        密码<input type="password" name="password" id="password"/>
        <br>
        <input type="submit" value="登录" id="enroll" onclick="enroll()"/>
    </form>
</div>
</body>
</html>